var express = require("express");
var router = express.Router();
const { UserModel } = require("../db");

/* GET users listing. */
router.get("/", function (req, res, next) {
  res.send("respond with a resource");
});

router.get("/user", async function (req, res, next) {
  // console.log("id", req.query.id);
  const rsp = await UserModel.findOne({ _id: req.query.id });

  console.log("rsp", rsp);

  res.send({
    code: 200,
    msg: "获取数据成功",
    data: {
      user: rsp,
    },
  });
});

module.exports = router;
